package cn.controllor.req;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;

import java.net.http.HttpHeaders;
@Controller
@RequestMapping("/req")
public class HeaderController {
    @RequestMapping("/header1")
    public void header1(@RequestHeader("User-Agent") String userAgent){
        System.out.println(userAgent);
    }

    @RequestMapping("/header2")
    public void header2(@RequestHeader HttpHeaders headers){
        System.out.println(headers);
    }

    /**
     * 只有包含了 指定的 请求头，才可以进行访问。
     */
    @RequestMapping(value = "/header3",headers = "haha")
    public void header3(){
        System.out.println("header3");
    }

}
